package tech.aistar.mapper.userLoginAndRegister;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tech.aistar.entity.User.Register;
import tech.aistar.entity.authordis.UserTable;

/**
 * Created by lenovo on 2019/9/25.
 */
public interface UserRegister {
    //从用户表根据手机查找 - 用来验证是否注册过
    @Select("select * from user_table where phone=#{value}")
    UserTable findByPhone(String phone);

    //主要将验证码插入注册表
    @Insert("insert into register(phone,password,email,ver_code) values (#{phone},#{password},#{email},#{code})")
    void insert(@Param("phone")String phoneNumber,@Param("password")String password,@Param("email")String email,@Param("code")String ver_code);

    //查询注册表 - 验证注册码是否输入正确
    @Select("select * from register where ver_code=#{code} and phone=#{phone}")
    Register findByCode(@Param("code") String Code,@Param("phone")String phoneNumber);

    //注册成功将用户插入用户表
    @Insert("insert into user_table(username,phone,password) values(#{username},#{phone},#{password})")
    void insertuser(@Param("username")String username,@Param("phone")String phoneNumber,@Param("password")String password);

    //将用户插入游记表
    @Insert("insert into note_author(user_id) values(#{values})")
    void insertNotes(Integer user_id);

    //获取用户自增id - 用来插入游记表
    @Select("select * from user_table where phone=#{value}")
    Integer findId(String phone);

}
